let  arr = [85, 24, 63, 45, 17, 31, 96, 50]
function quickSort (arr) {
    if (arr.length <= 1) { return arr; }
  var pivotIndex= Math.floor(arr.length / 2)
  var pivot = arr.splice(pivotIndex, 1)[0];
  var left = [];
  var right = [];
  for (let index = 0; index < arr.length; index++) {
       if (arr[index]< pivot) {
           left.push(arr[index])
       } else {
           right.push(arr[index])
       }
  }
  return quickSort(left).concat([pivot], quickSort(right))

}
console.log(quickSort (arr))